import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
let state = {
    count : 1,
    // loadnum : 10,
    // 登录的标志
    loginstate : false,
	loginaname: "",
	xiawuArr: [],
	num: 0,
	newnum: 1,
	activitydata: [],
	choosedata: []	
}

let mutations = {
	add(state) {
		state.count++;

	},
	// 改变登录状态
	changeLoginstate() {
		state.loginstate = !state.loginstate;
	},
	// 改变昵称
	changeLoginname(name) {
		state.loginname = name;
	},
	// 解析活动数据
	getActivityData() {
		let path = "/static/activity.json";
		fetch(path)
			.then(res => res.json())
			.then(
				function(res) {
					state.activitydata.push(...res.data.data);
					// console.log(state.count);
					// console.log(1,state.activitydata)
				}
			)
	},
	//解析 下午茶场景
	getXWCData() {
		fetch("./static/changjing/xiawucha.json")
			.then(res => res.json())
			.then(
				function(res) {
					//					state.xiawuArr.push(...res.data)
					console.log(res.data.dishes_list)
					state.xiawuArr.push(...res.data.dishes_list)
				})
	},

	// 食材选储数据解析
	getChooseData() {
		let path = "/static/choose.json";
		fetch(path)
			.then(res => res.json())
			.then(
				function(res) {
					state.choosedata.push(...res.data.data);
				})
	}
}

export default new Vuex.Store({
	state,
	mutations,	
})